<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.jiadakeji.ppm.modules.sys.utils.*" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>小区住户管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function() {

        });
        function page(n,s){
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/business/customer/">小区住户列表</a></li>
    <shiro:hasPermission name="business:customer:edit"><li><a href="${ctx}/business/customer/form">小区住户添加</a></li></shiro:hasPermission>
</ul>
<form:form id="searchForm" modelAttribute="customer" action="${ctx}/business/customer/addUserList?replaceId=${replaceId}&replaceName=${replaceName}" method="post" class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <ul class="ul-form">
        <li><label>姓名：</label>
            <form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
        </li>
        <li><label>电话：</label>
            <form:input path="mobile" htmlEscape="false" maxlength="16" class="input-medium"/>
        </li>
        <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
        <li class="clearfix"></li>
    </ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th>姓名</th>
        <th>电话</th>
        <th>性别</th>
        <th>openid</th>
        <th>昵称</th>
        <th>更新时间</th>
        <shiro:hasPermission name="business:customer:edit"><th>操作</th></shiro:hasPermission>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.list}" var="customer">
        <tr>
            <td>
                    ${customer.name}
            </td>
            <td>
                    ${customer.mobile}
            </td>
            <td>
                    ${customer.sex}
            </td>
            <td>
                    ${customer.openid}
            </td>
            <td>
                    ${customer.nickname}
            </td>
            <td>
                <fmt:formatDate value="${customer.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            <shiro:hasPermission name="business:customer:edit"><td>
                <div>
                    <button type="button" class="btn btn-xs btn-info" name="chooseBtn"  userName="${customer.name}" userId="${customer.id}" >
                        <i class="ace-icon glyphicon glyphicon-book"></i>选择
                    </button>
                </div>
            </td></shiro:hasPermission>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>
<script src="${pageContext.request.contextPath}/static/common/pop_win.js"></script>
<script type="text/javascript">
    jQuery(function($) {
        $("button[name=chooseBtn]").on("click", function() {
            var userId=$(this).attr("userId");
            var name=$(this).attr("userName");
            //console.log("userId",userId);
            //console.log("name",name);
            var form=parent.document.getElementById("inputForm");
            $(form).find("input[name='${replaceId}']").val(userId);
             $(form).find("input[name='${replaceName}']").val(name);
            parent.document.getElementById("popWinClose").click();

        });
    });
</script>
</body>
</html>